home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 4454 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.0 KB

  1. Path: polarnet.com!floyd
  2. From: floyd@polarnet.com (Floyd Davidson)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: HELP - why isn't ld working
  5. Date: 4 Feb 1996 21:57:11 GMT
  6. Organization: __________
  7. Message-ID: <4f3a3n$5nc@zippy.cais.net>
  8. References: <4etai7$22s@deadbird.db.erau.edu> <4f0kgb$6gj@umbc9.umbc.edu>
  9. Reply-To: floyd@tanana.polarnet.com
  10. NNTP-Posting-Host: tanana.polarnet.com
  11.  
  12. In article <4f0kgb$6gj@umbc9.umbc.edu>,
  13. Jonas J. Schlein <schlein@umbc.edu> wrote:
  14. >Darryl E. Marsee <marseed@news.db.erau.edu> wrote:
  15. >|>  gcc ex5.c ex5a.c
  16. >|> 
  17. >|> It produces a correctly executing a.out.  So far so good.
  18. ..
  19. >|>  gcc -c ex5.c
  20. >|>  gcc -c ex5a.c
  21. ...
  22. >|>  ld ex5.o ex5a.o -lc
  23. >
  24. >Tell him don't do that ;-). Either stick with the first way or instead of
  25. >using ld use gcc with the command line:
  26. >
  27. >gcc ex5.o ex5a.o
  28.  
  29. True enough, but why not at least give someone an idea of what
  30. is going on!  The command "gcc ex5.o ex5a.o" does a lot more
  31. than just call ld as "ld ex5.o ex5a.o -lc", and knowing what it
  32. actually does might clear up a lot of confusion about the why
  33. and when of various gcc command lines.
  34.  
  35. Darryl, try these to command lines to see what is happening, and
  36. then you can post questions about what it is doing:
  37.  
  38.   gcc -v ex5.c ex5a.c
  39.  
  40. and
  41.  
  42.   gcc -c ex5.c
  43.   gcc -c ex5a.c
  44.   gcc -v ex5.o ex5a.o
  45.  
  46. The -v will cause verbose output from gcc, which means it will
  47. show you the command lines it uses to call other programs,
  48. including ld.  If nothing else it will convince you that calling
  49. ld directly isn't as easy as using gcc to do it for you!  For
  50. example:
  51.  
  52. tanana:floyd /tmp >gcc -v xx.o
  53. Reading specs from /usr/lib/gcc-lib/i486-linux/2.7.0/specs
  54. gcc version 2.7.0
  55.  /usr/i486-linux/bin/ld -m elf_i386 -dynamic-linker \
  56.  /lib/ld-linux.so.1 /usr/lib/crt1.o /usr/lib/crti.o \
  57.  /usr/lib/crtbegin.o -L/usr/lib/gcc-lib/i486-linux/2.7.0 \
  58.  -L/usr/i486-linux/lib xx.o -lgcc -lc -lgcc /usr/lib/crtend.o \
  59.  /usr/lib/crtn.o
  60.  
  61. (The '\' characters are where I have wrapped the lines.)
  62.  
  63. Floyd
  64.  
  65. -- 
  66. Floyd L. Davidson          Salcha, Alaska         floyd@tanana.polarnet.com
  67.